<template>
  <BasicLayout>
    <template #wrapper>
      <el-card class="box-card">
<!--        <el-form ref="queryForm" :model="queryParams" :inline="true" label-width="68px">-->

<!--          <el-form-item>-->
<!--            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>-->
<!--            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>-->
<!--          </el-form-item>-->
<!--        </el-form>-->

        <el-table v-loading="loading" :data="torderList">
          <el-table-column label="用户名" width="200px" align="center" prop="username" :show-overflow-tooltip="true"/>
          <el-table-column label="订单号" width="300px" align="center" prop="orderNo" :show-overflow-tooltip="true"/>
          <el-table-column label="金额" width="300px" align="center" prop="amount" :show-overflow-tooltip="true"/>
          <el-table-column label="产品名称" width="100px" align="center" prop="product" :show-overflow-tooltip="true"/>
          <el-table-column label="时间" width="200px" align="center" prop="createdAt" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createdAt) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="状态" width="150px" align="center" prop="statusResult" :show-overflow-tooltip="true"/>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageIndex"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-card>
    </template>
  </BasicLayout>
</template>

<script>
  import {listTOrder} from '@/api/torder'
  import store from "@/store";

  export default {
    name: 'TOrder',
    components: {
    },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 总条数
        total: 0,
        // 弹出层标题
        title: '',
        // 是否显示弹出层
        open: false,
        isEdit: false,
        fileOpen: false,
        fileIndex: undefined,
        // 类型数据字典
        typeOptions: [],
        torderList: [],

        // 关系表类型

        // 查询参数
        queryParams: {
          pageIndex: 1,
          pageSize: 10,

        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {}
      }
    },
    created() {
      this.queryParams.userId = this.$route.params && this.$route.params.userId
      this.queryParams.type =  this.$route.params && this.$route.params.type
      this.getList()
    },
    methods: {
      /** 查询参数列表 */
      getList() {
        if (this.queryParams.userId === undefined && store.getters.roles[0] == 'customer_for_c') {
          this.queryParams.userId = parseInt(store.getters.userId)
        }
        this.loading = true
        listTOrder(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
            this.torderList = response.data.list
            this.total = response.data.count
            this.loading = false
          }
        )
      },
      // 取消按钮
      cancel() {
        this.open = false
        this.reset()
      },
      // 表单重置
      reset() {
        this.form = {

          OID: undefined,
          userId: undefined,
          orderNo: undefined,
          payType: undefined,
          amount: undefined,
          status: undefined,
          minusAmount: undefined,
          ip: undefined,
        }
        this.resetForm('form')
      },
    }
  }
</script>
